{template modoer_header}
<script type="text/javascript" src="{URLROOT}/static/javascript/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
function change_password () {
	$.post(Url('member/index/ac/myset/op/changepw/type/login'), {in_ajax:1}, 
		function(result) {
		if (result.match(/<form.+method="post".+>/)) {
			dlgOpen('更改登录密码', result, 300);
		} else {
			myAlert(result);
		}
	});
}
function change_paypw () {
    $.post(Url('member/index/ac/myset/op/changepw/type/pay'), {in_ajax:1}, 
        function(result) {
        if (result.match(/<form.+method="post".+>/)) {
            dlgOpen('更改支付密码', result, 300);
        } else {
            myAlert(result);
        }
    });
}
function change_mobile () {
	$.post(Url('member/index/ac/myset/op/changemobile'), {in_ajax:1}, 
		function(result) {
		if (result.match(/<form.+method="post".+>/)) {
			dlgOpen('更改手机号码', result, 410, 120);
		} else {
			myAlert(result);
		}
	});
}

function change_mobile_send () {
    var mobile = $('#mobile').val().trim();
    if(!mobile) {
        msgOpen('对不起，您未填写手机号码。');
        return;
    }
	$.post(Url('member/index/ac/myset/op/changemobile/do/mobile'), {mobile:mobile, in_ajax:1}, 
        function(result) {
		if (result=='OK') {
			change_mobile_send_verify(mobile);
		} else if(is_message(result)) {
			myAlert(result);
		} else {
            msgOpen(result);
        }
	});
}

function change_mobile_send_verify (mobile) {
	$.post(Url('member/index/ac/myset/op/changemobile/do/send'), {mobile:mobile, in_ajax:1}, 
        function(result) {
		if (result=='OK') {
			msgOpen('手机号验证码已发送，请注意查收。');
        } else if(is_numeric(result)) {
            msgOpen('请等待 '+result+' 秒后再发送验证码。');
		} else if(is_message(result)) {
			myAlert(result);
		} else {
            msgOpen('手机号验证码发送失败。');
        }
	});
}

function change_mobile_check() {
    var serial = $('#serial').val().trim();
    if(!serial) {
        msgOpen('对不起，您未输入验证码。');
        return;
    }
	$.post(Url('member/index/ac/myset/op/changemobile/do/check'), {serial:serial, in_ajax:1}, 
        function(result) {
		if (result=='OK') {
            msgOpen('手机验证成功！');
            $('#mymobile').text($('#mobile').val().trim());
            dlgClose();
		} else if(is_message(result)) {
			myAlert(result);
		} else {
            msgOpen('手机验证失败！');
        }
	});
}

function member_set_alipay() {
    $.mytip.show('正在获取...');
    $.post(Url('member/index/ac/myset/op/setalipay'), {in_ajax:1}, 
        function(result) {
        if(is_message(result)) {
            myAlert(result);
        } else if(is_email(result)) {
            $('#myalipay').html(result);
            $('#alipay_op').hide();
            $.mytip.close('获取成功，已保存');
        } else {
            alert('啊哦，出错了，请联系网站管理员！');
        }
    });
}

function forget_paypw() {
    $.post(Url('member/index/ac/myset/op/forget_paypw'), {in_ajax:1}, 
        function(result) {
        if (result.match(/<form.+method="post".+>/)) {
            dlgOpen('忘记支付密码', result, 350);
        } else {
            myAlert(result);
        }
    });
}

function forget_paypw_seccode_send(type) {
    if(type!='mobile'&&type!='email') {
        alert('对不起，无效的验证码发送方式。');
        return;
    }
    msgOpen('正在处理，请稍候...');
    send_btn_status(true, '#frm .J_send_btn');
    $.post(
        Url('member/index/ac/myset/op/seccode_send'),
        {'type':type,'action':'forget_paypw', in_ajax:1}, 
        function(result) {
            msgClose();
            if(result=='ok') {
                send_btn_status_countdown();
                alert('验证码已发送，请在接收到验证码（验证码有效期为30分钟），请将输入到下方文本框，并设置新的支付密码。');
            } else {
                myAlert(result);
            }
        }
    );
}

function change_email() {
    $.post(Url('member/index/ac/myset/op/change_email'), {in_ajax:1}, 
        function(result) {
        if (result.match(/<form.+method="post".+>/)) {
            dlgOpen('修改邮箱', result, 500);
        } else {
            myAlert(result);
        }
    });
}

function change_email_seccode_send(type) {
    if(type!='mobile'&&type!='email') {
        alert('对不起，无效的验证码发送方式。');
        return;
    }
    msgOpen('正在处理，请稍候...');
    send_btn_status(true, '#frm .J_send_btn');
    $.post(
        Url('member/index/ac/myset/op/seccode_send'),
        {'type':type,'action':'change_email', in_ajax:1}, 
        function(result) {
            msgClose();
            if(result=='ok') {
                send_btn_status_countdown('#frm .J_send_btn');
                alert('验证码已发送，请在接收到验证码（验证码有效期为30分钟），请将输入到下方文本框。');
            } else {
                myAlert(result);
            }
        }
    );
}

function change_email_new_seccode_send(email) {
    if(!email||!is_email(email)) {
        alert('对不起，新邮箱帐号未填写或格式错误。');
        return;
    }
    send_btn_status(true, '#frm .J_new_send_btn');
    $.post(
        Url('member/index/ac/myset/op/change_email/do/check_email'),
        {'email':email, 'in_ajax':1}, 
        function(result) {
            msgClose();
            if(result=='ok') {
                msgOpen('正在处理，请稍候...');
                $.post(
                    Url('member/index/ac/myset/op/seccode_send'),
                    {'type':'email', 'action':'check_new_email', 'email':email, 'in_ajax':1}, 
                    function(result) {
                        msgClose();
                        if(trim(result)=='ok') {
                            send_btn_status_countdown('#frm .J_new_send_btn');
                            alert('新邮箱验证码已发送，请在接收到验证码（验证码有效期为30分钟），请将输入到下方文本框。');
                        } else {
                            myAlert(result);
                        }
                    }
                );
            } else {
                send_btn_status(false, '#frm .J_new_send_btn');
                myAlert(result);
            }
        }
    );
}

function send_btn_status(disabled,filter_id) {
    if(disabled) {
        $(filter_id).attr('disabled',disabled).addClass('buttn_diabled');
    } else {
        $(filter_id).attr('disabled',disabled).removeClass('buttn_diabled');
    }
}

var countdown_step = 60;
var countdown_time = null;
function send_btn_status_countdown(filter_id) {
    $(filter_id).each(function() {
        $(this).attr('data-text', $(this).text());
    });
    countdown_time = setInterval(function() {
        countdown_step--;
        if(countdown_step < 0) {
            countdown_step = 60;
            send_btn_status(false);
            $(filter_id).each(function() {
                $(this).text($(this).attr('data-text'));
            });
            clearInterval(countdown_time);
        } else {
            $(filter_id).each(function() {
                $(this).text($(this).attr('data-text')+'('+countdown_step+')');
            });
        }
    }, 1000);
}
</script>
<div id="body">
<div class="myhead"></div>
<div class="mymiddle">
    <div class="myleft">
        <!--{template 'menu','member','member'}-->
    </div>
    <div class="myright">
        <div class="myright_top"></div>
        <div class="myright_middle">
            <h3>个人设置</h3>
            <div class="mainrail">
                <form method="post" action="{url member/index/ac/myset/op/save}">
                    <table width="100%" cellspacing="0" cellpadding="0" class="maintable">
                        <tr><td align="right">用户名：</td><td>$user->username</td></tr>
                        <tr>
                            <td width="80" align="right">电子邮件：</td>
                            <td>
                                $user->email
                                [<a href="javascript:"onclick="change_email();">更改</a>]
                            </td>
                        </tr>
                        <tr>
                            <td align="right">登录密码：</td>
                            <td>
                                **********
                                <!--{if $user->passport['enable']}-->
                                [<a href="$user->passport['cpwd_url']">修改</a>]
                                <!--{else}-->
                                [<a href="javascript:"onclick="change_password();">更改</a>]
                                <!--{/if}-->
                            </td>
                        </tr>
                        <tr>
                            <td align="right">支付密码：</td>
                            <td>
                                **********
                                [<a href="javascript:"onclick="change_paypw();">更改</a>]
                                [<a href="javascript:"onclick="forget_paypw();">忘记密码</a>]
                            </td>
                        </tr>
                        <tr>
                            <td align="right">手机号码：</td>
                            <td>
                                <span id="mymobile">$user->mobile</span>
                                {if $usdmobile}
                                    {if $user->mobile}
                                    <a href="javascript:"onclick="change_mobile();">[更改]</a>
                                    {else}
                                    <a href="javascript:"onclick="change_mobile();">添加</a>
                                    {/if}
                                {else}
                                    <span class="font_3">系统未开启手机短信功能</span>
                                {/if}
                                <div id="change_mobile"></div>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">支付宝：</td>
                            <td>
                                <input type="text" name="profile[alipay]" value="$user->alipay" class="t_input" style="width:300px;">
                            </td>
                        </tr>
                        <tr>
                            <td align="right">PayPal：</td>
                            <td>
                                <input type="text" name="profile[paypal]" value="$user->paypal" class="t_input" style="width:300px;">
                            </td>
                        </tr>
                        <tr>
                            <td align="right">真实姓名：</td>
                            <td><input type="text" name="profile[realname]" value="$user->realname" class="t_input" style="width:300px;"></td>
                        </tr>
                        <tr>
                            <td align="right">性别：</td>
                            <td>
                                <select name="profile[gender]">
                                    <option value="0">保密</option>
                                    <option value="1"{if $user->gender==='1'}selected="selected"{/if}>男性</option>
                                    <option value="2"{if $user->gender==='2'}selected="selected"{/if}>女性</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">生日：</td>
                            <td><input type="text" name="profile[birthday]" value="$user->birthday" class="t_input" style="width:300px;" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})"></td>
                        </tr>
                        <tr>
                            <td align="right">QQ：</td>
                            <td><input type="text" name="profile[qq]" value="$user->qq" class="t_input" style="width:300px;"></td>
                        </tr>
                        <tr>
                            <td align="right">微信：</td>
                            <td><input type="text" name="profile[wechat]" value="$user->wechat" class="t_input" style="width:300px;"></td>
                        </tr>
                        <tr>
                            <td align="right">地址：</td>
                            <td><input type="text" name="profile[address]" value="$user->address" class="t_input" style="width:300px;"></td>
                        </tr>
                        <tr>
                            <td align="right">邮编：</td>
                            <td><input type="text" name="profile[zipcode]" value="$user->zipcode" class="t_input" style="width:300px;"></td>
                        </tr>
                        <tr>
                            <td align="right"></td>
                            <td><button type="submit" name="dosubmit" value="yes">提交</button></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div class="mybottom"></div>
</div>
 
<!--{eval footer();}-->